(function(window, document) {
    angular
        .module('app')
        .factory('loadingInterceptor', loadingInterceptor);

    loadingInterceptor.$inject = ['$rootScope'];

    function loadingInterceptor ($rootScope) {
        var service = {};
        service.request = function(config) {
            $rootScope.loading = true;
            return config;
        };

        service.response = function(response) {
            $rootScope.loading = false;
            return response;
        };

        return service;
    }
})(window, document);
